package com.mrjy.common.qtz;

import java.util.TimerTask;

import javax.servlet.ServletContext;

import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.WebApplicationContext;

import com.mrjy.maintain.bo.IUserMemberInfoBo;

/**
 * 检查会员状态和过期时间-并发送消息
 * @author Administrator
 *
 */
public class MemberStateTimeTask extends TimerTask {

	private ServletContext context = null;
	
//	public static boolean isRunning = false;
	
	public MemberStateTimeTask() {
		super();
	}
	
	public MemberStateTimeTask(ServletContext context) {
		this.context = context;
	}
	
	@Override
	public void run() {
//		ApplicationContext ac1 =WebApplicationContextUtils.getRequiredWebApplicationContext(context);
//		IUserInfoBo userInfoBo = (IUserInfoBo) ac1.getBean(IUserInfoBo.class);
		try {
			WebApplicationContext wac = ContextLoader.getCurrentWebApplicationContext();
			IUserMemberInfoBo userMemberInfoBo = wac.getBean(IUserMemberInfoBo.class);
			
			userMemberInfoBo.txCheckUserMemberExpired();
			context.log("会员状态检查成功");	
		} catch (Exception e) {
			e.printStackTrace();
			context.log("会员状态检查失败");
		
		}
	}

}
